package com.rxtxdemo.rxtxdemo.applicationevent.listener;

import com.rxtxdemo.rxtxdemo.applicationevent.even.ComRegisterEvent;
import com.rxtxdemo.rxtxdemo.demo.MyLister;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.util.Map;

//执行指令策略1
@Service
@Slf4j
public class J1Service {

    @EventListener
    @Async
    public void onApplicationEvent(ComRegisterEvent arg0) throws InterruptedException {
        MyLister.sum++;
        Map m = (Map) arg0.getSource();
        log.info("获得第一个检测内容：开始延迟j11111111: [{}]", Thread.currentThread().getId());
        Thread.sleep(1000);
//        System.out.println("异步执行j1111111111！！！"+ Thread.currentThread().getId());
//        System.out.println("线程id：" + Thread.currentThread().getId());
        System.out.println("线程名称：" + Thread.currentThread().getName());
//        if(m.get("one").equals("false")){
//            log.info("等待检测设备开启。。。。。。。。。。。。");
//            Thread.sleep(5000);
//            m.put("one","true");
//            log.info("设备状态改为开启#############");
//        }else{
//
//            log.info("J1设备开启状态&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&");
//        }
//        m.put("two", String.valueOf(RandomUtil.randomInt(1,30)));
//        m.put("three",String.valueOf(RandomUtil.randomInt(1,30)));

    }

}
